package com.gxar.uaa.server.base.dubbo;

import com.gxar.common.warning.ApiLog;
import com.gxar.uaa.api.client.IRoleClient;
import com.gxar.uaa.api.dto.role.SysRole;
import com.gxar.uaa.server.db.service.RoleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

/**
 * @author linsy
 * @version 1.0
 * @created 2024/1/24 14:33
 */
@Slf4j
@DubboService(version = "1.0.0")
@RequiredArgsConstructor
public class IRoleClientImpl implements IRoleClient {

    private final RoleService roleService;

    @Override
    public List<SysRole> findRolesByUserId(String app, Long id) {
        return roleService.findRolesByUserId(app, id);
    }

    @Override
    @ApiLog
    public void deleteUser(List<Long> userId) {
        if (CollectionUtils.isEmpty(userId)) {
            return;
        }
        roleService.batchDelete(userId);
    }

}
